local key=KEYS
local num=ARGV
local skuInventory = "inventory:num:"

for i = 1, #key do

    local exists = redis.call("EXISTS",skuInventory ..key[i]);

    local inventoryNum = redis.call("GET", skuInventory ..key[i])


    if exists == 0 then
        inventoryNum = 0
        return 0
    end


    if tonumber(inventoryNum) >= tonumber(num[i]) then
        redis.call("DECRBY", skuInventory ..key[i], tonumber(num[i]))
    else
        return 0
    end

    return 1
end




